<template>
  <div>
    <el-menu
      class="menu-bar"
      @open="handleOpen"
      @close="handleClose"
      :collapse="isCollapse"
      :unique-opened="true"
      :default-active="$route.path"
    >
      <menu-item :menuList="menuList"></menu-item>
    </el-menu>
  </div>
</template>

<script>
import MenuItem from "./MenuItem.vue";
export default {
  name: "MenuBar",
  components: {
    MenuItem,
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
  computed: {
    menuList: {
      get() {
        return this.$store.state.MenuStore.menuList;
      },
      set(val) {
        this.$store.state.MenuStore.menuList = val;
      },
    },
    isCollapse: {
      get() {
        return this.$store.state.MenuStore.isCollapse;
      },
      set(val) {
        this.$store.state.MenuStore.isCollapse = val;
      },
    },
  },
};
</script>

<style lang="scss" scoped>
.menu-bar:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>